<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>苹果第三方登录 | Albert Yuan's Blog</title><meta name="keywords" content="ios"><meta name="author" content="Albert Yuan"><meta name="copyright" content="Albert Yuan"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta name="referrer" content="no-referrer"><meta name="description" content="Sign In with Apple登录支持的最低iOS系统要求是iOS13，凡是包含第三方登录功能的App，必须带有苹果登录功能，且样式需要满足苹果要求  前端部分1、开发Sign In with Apple的注意事项  需要在苹果后台打开sign in with Apple 选项 在Xcode中的 Signing &amp; Capabilities中添加Sign In With Apple">
<meta property="og:type" content="article">
<meta property="og:title" content="苹果第三方登录">
<meta property="og:url" content="https://yllove.gitee.io/2021/10/26/iOS/%E8%8B%B9%E6%9E%9C%E7%AC%AC%E4%B8%89%E6%96%B9%E7%99%BB%E5%BD%95/index.html">
<meta property="og:site_name" content="Albert Yuan&#39;s Blog">
<meta property="og:description" content="Sign In with Apple登录支持的最低iOS系统要求是iOS13，凡是包含第三方登录功能的App，必须带有苹果登录功能，且样式需要满足苹果要求  前端部分1、开发Sign In with Apple的注意事项  需要在苹果后台打开sign in with Apple 选项 在Xcode中的 Signing &amp; Capabilities中添加Sign In With Apple">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F1625283-e61716c6b5265137.png&refer=http%3A%2F%2Fupload-images.jianshu.io&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1637827636&t=1d207d66ff8d9377112e4eaef5dd90a5">
<meta property="article:published_time" content="2021-10-26T06:31:04.581Z">
<meta property="article:modified_time" content="2021-10-26T08:33:45.893Z">
<meta property="article:author" content="Albert Yuan">
<meta property="article:tag" content="Objective-c">
<meta property="article:tag" content="ruby">
<meta property="article:tag" content="Sign in with Apple">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F1625283-e61716c6b5265137.png&refer=http%3A%2F%2Fupload-images.jianshu.io&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1637827636&t=1d207d66ff8d9377112e4eaef5dd90a5"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="https://yllove.gitee.io/2021/10/26/iOS/%E8%8B%B9%E6%9E%9C%E7%AC%AC%E4%B8%89%E6%96%B9%E7%99%BB%E5%BD%95/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.css" media="print" onload="this.media='all'"><script src="https://fastly.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.js" defer></script><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: {"appId":"X8NS0XSX99","apiKey":"b9d4530647c8b5bf7928a04c47752ad7","indexName":"albertyuan","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://fastly.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://fastly.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://fastly.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://fastly.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://fastly.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '苹果第三方登录',
  isPost: true,
  isHome: false,
  isHighlightShrink: true,
  isToc: true,
  postUpdate: '2021-10-26 16:33:45'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/blog/atom.xml" title="Albert Yuan's Blog" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/blog/img/favicon.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">155</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">56</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F1625283-e61716c6b5265137.png&amp;refer=http%3A%2F%2Fupload-images.jianshu.io&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1637827636&amp;t=1d207d66ff8d9377112e4eaef5dd90a5')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">Albert Yuan's Blog</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">苹果第三方登录</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-10-26T06:31:04.581Z" title="发表于 2021-10-26 14:31:04">2021-10-26</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-10-26T08:33:45.893Z" title="更新于 2021-10-26 16:33:45">2021-10-26</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/iOS/">iOS</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/iOS/Objective-c/">Objective-c</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>6分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="苹果第三方登录"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><blockquote>
<p><code>Sign In with Apple</code>登录支持的最低iOS系统要求是iOS13，凡是包含第三方登录功能的App，必须带有<strong>苹果登录</strong>功能，且样式需要满足苹果要求</p>
</blockquote>
<h4 id="前端部分"><a href="#前端部分" class="headerlink" title="前端部分"></a>前端部分</h4><h6 id="1、开发Sign-In-with-Apple的注意事项"><a href="#1、开发Sign-In-with-Apple的注意事项" class="headerlink" title="1、开发Sign In with Apple的注意事项"></a>1、开发<code>Sign In with Apple</code>的注意事项</h6><blockquote>
<ul>
<li>需要在苹果后台打开sign in with Apple 选项</li>
<li>在<code>Xcode中的 Signing &amp; Capabilities</code>中添加<code>Sign In With Apple</code></li>
</ul>
</blockquote>
<h6 id="2、iOS-Sign-In-with-Apple流程"><a href="#2、iOS-Sign-In-with-Apple流程" class="headerlink" title="2、iOS Sign In with Apple流程"></a>2、iOS Sign In with Apple流程</h6><blockquote>
<ol>
<li>添加 Sign In with Apple 登录按钮，设置 ASAuthorizationAppleIDButton 相关布局，并添加按钮点击响应事件</li>
<li>在响应事件执行登录操作，获取userid,授权码code,email,fullName</li>
<li>后端验证(如果需要)</li>
</ol>
</blockquote>
<h6 id="3、代码实现"><a href="#3、代码实现" class="headerlink" title="3、代码实现"></a>3、代码实现</h6><ul>
<li>添加Sign In with Apple登录按钮，设置ASAuthorizationAppleIDButton相关布局，并添加按钮点击响应事件。当然苹果也允许自定义苹果登录按钮的样式，样式要求详见这个文档：<a target="_blank" rel="noopener" href="https://links.jianshu.com/go?to=https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/">Human Interface Guidelines:自定义登录按钮文档规范</a></li>
</ul>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="type">void</span>)configUI&#123;</span><br><span class="line">    <span class="comment">// 用于展示Sign In With Apple 登录过程的信息</span></span><br><span class="line">    <span class="keyword">if</span> (@available(iOS <span class="number">13.0</span>, *)) &#123;</span><br><span class="line">        <span class="comment">// Sign In With Apple Button</span></span><br><span class="line">        ASAuthorizationAppleIDButton *appleIDBtn = [ASAuthorizationAppleIDButton buttonWithType:ASAuthorizationAppleIDButtonTypeDefault style:ASAuthorizationAppleIDButtonStyleWhite];</span><br><span class="line">        appleIDBtn.frame = <span class="built_in">CGRectMake</span>(<span class="number">30</span>, <span class="keyword">self</span>.view.bounds.size.height - <span class="number">180</span>, <span class="keyword">self</span>.view.bounds.size.width - <span class="number">60</span>, <span class="number">100</span>);</span><br><span class="line">        <span class="comment">//    appleBtn.cornerRadius = 22.f;</span></span><br><span class="line">        [appleIDBtn addTarget:<span class="keyword">self</span> action:<span class="keyword">@selector</span>(handleAuthorizationAppleIDButtonPress) forControlEvents:<span class="built_in">UIControlEventTouchUpInside</span>];</span><br><span class="line">        [<span class="keyword">self</span>.view addSubview:appleIDBtn];</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">// 处理登录授权</span></span><br><span class="line">- (<span class="type">void</span>)handleAuthorizationAppleIDButtonPress&#123;</span><br><span class="line">    <span class="keyword">if</span> (@available(iOS <span class="number">13.0</span>, *)) &#123;</span><br><span class="line">  </span><br><span class="line">     		<span class="comment">// 基于用户的Apple ID授权用户，生成用户授权请求的一种机制（授权信息提供方）</span></span><br><span class="line">        ASAuthorizationAppleIDProvider *appleIDProvider = [[ASAuthorizationAppleIDProvider alloc] init];</span><br><span class="line">        <span class="comment">// 创建新的AppleID 授权请求（授权信息请求）</span></span><br><span class="line">        ASAuthorizationAppleIDRequest *appleIDRequest = [appleIDProvider createRequest];</span><br><span class="line">        <span class="comment">// 在用户授权期间请求的联系信息（授权信息内容）</span></span><br><span class="line">        appleIDRequest.requestedScopes = @[ASAuthorizationScopeFullName, ASAuthorizationScopeEmail];</span><br><span class="line">        </span><br><span class="line">      </span><br><span class="line">      <span class="comment">// 由ASAuthorizationAppleIDProvider创建的授权请求 管理（授权请求的控制器）</span></span><br><span class="line">        ASAuthorizationController *authorizationController = [[ASAuthorizationController alloc] initWithAuthorizationRequests:@[appleIDRequest]];</span><br><span class="line">      </span><br><span class="line">        <span class="comment">// 设置授权控制器通知授权请求的成功与失败的代理ASAuthorizationControllerDelegate</span></span><br><span class="line">        authorizationController.delegate = <span class="keyword">self</span>;</span><br><span class="line">        <span class="comment">// 设置提供 展示上下文的代理，在这个上下文中 系统可以展示授权界面给用户ASAuthorizationControllerPresentationContextProviding</span></span><br><span class="line">       authorizationController.presentationContextProvider = <span class="keyword">self</span>;</span><br><span class="line">      </span><br><span class="line">        <span class="comment">// 在控制器初始化期间启动授权流</span></span><br><span class="line">        [authorizationController performRequests];</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ul>
<li>获取授权码：实现ASAuthorizationControllerDelegate代理</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br></pre></td><td class="code"><pre><span class="line">#pragma mark - ASAuthorizationControllerDelegate</span><br><span class="line">//@optional 授权成功地回调</span><br><span class="line">- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization&#123;</span><br><span class="line">    NSLog(@&quot;授权完成:::%@&quot;, authorization.credential);</span><br><span class="line">    NSLog(@&quot;%s&quot;, __FUNCTION__);</span><br><span class="line">    NSLog(@&quot;%@&quot;, controller);</span><br><span class="line">    NSLog(@&quot;%@&quot;, authorization);</span><br><span class="line"></span><br><span class="line">    // 测试配置UI显示</span><br><span class="line">    NSMutableString *mStr = [NSMutableString string];</span><br><span class="line"></span><br><span class="line">  //授权登录</span><br><span class="line">    if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) &#123;</span><br><span class="line">        // 用户登录使用ASAuthorizationAppleIDCredential</span><br><span class="line">        ASAuthorizationAppleIDCredential *appleIDCredential = authorization.credential;</span><br><span class="line">        NSString *user = appleIDCredential.user;</span><br><span class="line">        NSString *familyName = appleIDCredential.fullName.familyName;</span><br><span class="line">        NSString *givenName = appleIDCredential.fullName.givenName;</span><br><span class="line">        NSString *email = appleIDCredential.email;</span><br><span class="line">        NSData *identityToken = appleIDCredential.identityToken;</span><br><span class="line">        NSData *authorizationCode = appleIDCredential.authorizationCode;</span><br><span class="line">        </span><br><span class="line">      // 执行具体登录操作：验证登录或创建用户</span><br><span class="line">      // Create an account in your system.</span><br><span class="line">      // For the purpose of this demo app, store the userIdentifier in the keychain.</span><br><span class="line">      //  需要使用钥匙串的方式保存用户的唯一信息</span><br><span class="line">      // [YostarKeychain save:KEYCHAIN_IDENTIFIER(@&quot;userIdentifier&quot;) data:user];</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">  </span><br><span class="line">  //钥匙串登录方式（一般用不上）</span><br><span class="line">  else if ([authorization.credential isKindOfClass:[ASPasswordCredential class]])&#123;</span><br><span class="line">        </span><br><span class="line">      // Sign in using an existing iCloud Keychain credential.</span><br><span class="line">      // 用户登录使用现有的密码凭证</span><br><span class="line">        	ASPasswordCredential *passwordCredential = authorization.credential;</span><br><span class="line">      // 密码凭证对象的用户标识 用户的唯一标识</span><br><span class="line">      		NSString *user = passwordCredential.user;</span><br><span class="line">      // 密码凭证对象的密码</span><br><span class="line">        	NSString *password = passwordCredential.password;</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        NSLog(@&quot;授权信息均不符&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">// 授权失败的回调</span><br><span class="line">- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error&#123;</span><br><span class="line">    // Handle error.</span><br><span class="line">    NSLog(@&quot;Handle error：%@&quot;, error);</span><br><span class="line">    NSString *errorMsg = nil;</span><br><span class="line">    switch (error.code) &#123;</span><br><span class="line">        case ASAuthorizationErrorCanceled:</span><br><span class="line">            errorMsg = @&quot;用户取消了授权请求&quot;;</span><br><span class="line">            break;</span><br><span class="line">        case ASAuthorizationErrorFailed:</span><br><span class="line">            errorMsg = @&quot;授权请求失败&quot;;</span><br><span class="line">            break;</span><br><span class="line">        case ASAuthorizationErrorInvalidResponse:</span><br><span class="line">            errorMsg = @&quot;授权请求响应无效&quot;;</span><br><span class="line">            break;</span><br><span class="line">        case ASAuthorizationErrorNotHandled:</span><br><span class="line">            errorMsg = @&quot;未能处理授权请求&quot;;</span><br><span class="line">            break;</span><br><span class="line">        case ASAuthorizationErrorUnknown:</span><br><span class="line">            errorMsg = @&quot;授权请求失败未知原因&quot;;</span><br><span class="line">            break;</span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">//@optional ASAuthorizationControllerPresentationContextProviding</span><br><span class="line">// 告诉代理应该在哪个window 展示内容给用户:一般固定以下实现即可</span><br><span class="line">- (ASPresentationAnchor)presentationAnchorForAuthorizationController:(ASAuthorizationController *)controller&#123;</span><br><span class="line">    // 返回window</span><br><span class="line">    return self.view.window;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ul>
<li>在授权登录成功回调中，我们可以拿到以下几类数据：</li>
</ul>
<blockquote>
<p><strong>UserID:</strong>(user)<code>Unique, stable, team-scoped user ID</code>，苹果用户唯一标识符，该值在同一个开发者账号下的所有<code>App</code>下是一样的，开发者可以用该唯一标识符与自己后台系统的账号体系绑定起来（这与国内的<code>微信、QQ、微博</code>等第三方登录流程基本一致）</p>
<p><strong>Verification data:</strong>(authorizationCode)<code>Identity token, code</code>，验证数据，用于传给开发者后台服务器，然后开发者服务器再向苹果的身份验证服务端验证，本次授权登录请求数据的有效性和真实性，详见<a target="_blank" rel="noopener" href="https://links.jianshu.com/go?to=https://developer.apple.com/documentation/signinwithapplerestapi">Sign In with Apple REST API</a></p>
<p><strong>Account information:</strong><code>Name, verified email</code>，苹果用户信息，包括全名、邮箱等，注意：<strong>如果玩家登录时拒绝提供真实的邮箱账号，苹果会生成虚拟的邮箱账号</strong></p>
</blockquote>
<hr>
<h4 id="后端验证部分"><a href="#后端验证部分" class="headerlink" title="后端验证部分"></a>后端验证部分</h4><blockquote>
<p>关于验证的这一步，需要传递授权码给自己的服务端，自己的服务端调用苹果<code>API</code>去校验授权码<a target="_blank" rel="noopener" href="https://links.jianshu.com/go?to=https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens">Generate and validate tokens</a>。如果验证成功，可以根据<code>userIdentifier</code>判断账号是否已存在，若存在，则返回自己账号系统的登录态，若不存在，则创建一个新的账号，并返回对应的登录状态给<code>App</code></p>
</blockquote>
<h6 id="1、前端配置"><a href="#1、前端配置" class="headerlink" title="1、前端配置"></a>1、前端配置</h6><blockquote>
<p>前端获取到<code>Apple ID</code>的用户信息后，需要把<code>code</code>传给后端，后端再调用苹果的验证接口进行验证，通过验证接口返回的数据进行校验,code<code>就是前端获取到的</code>authorizationCode</p>
</blockquote>
<h6 id="2、苹果验证接口：https-appleid-apple-com-auth-token"><a href="#2、苹果验证接口：https-appleid-apple-com-auth-token" class="headerlink" title="2、苹果验证接口：https://appleid.apple.com/auth/token"></a>2、苹果验证接口：<code>https://appleid.apple.com/auth/token</code></h6><p><strong>必传参数</strong>：</p>
<blockquote>
<p><strong>client_id</strong>：app的 bundle identifier<br> <strong>code</strong>：手机端获取到的 authorizationCode<br> <strong>grant_type</strong>：传入固定字符串 authorization_code<br> <strong>client_secret</strong>：秘钥</p>
</blockquote>
<h6 id="3、秘钥client-secret的生成"><a href="#3、秘钥client-secret的生成" class="headerlink" title="3、秘钥client_secret的生成"></a>3、<strong>秘钥client_secret</strong>的生成</h6><p>使用<code>ruby</code>代码生成<strong>client_secret</strong>:</p>
<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">require</span> <span class="string">&quot;jwt&quot;</span></span><br><span class="line"></span><br><span class="line">key_file = <span class="string">&quot;/Users/albertyuan/Downloads/AuthKey_7F839WR2C8.p8&quot;</span> <span class="comment">#在苹果开发者后台的keys选项下配置生成</span></span><br><span class="line">team_id = <span class="string">&quot;FN48ZWF64X&quot;</span></span><br><span class="line">client_id = <span class="string">&quot;com.HQWK.www.SignInwithApple&quot;</span></span><br><span class="line">key_id = <span class="string">&quot;7F839WR2C8&quot;</span> <span class="comment">#在苹果开发者后台的keys选项下配置生成</span></span><br><span class="line">validity_period = <span class="number">180</span> <span class="comment"># In days. Max 180 (6 months) according to Apple docs.</span></span><br><span class="line"></span><br><span class="line">private_key = <span class="title class_">OpenSSL::PKey::EC</span>.new <span class="variable constant_">IO</span>.read key_file</span><br><span class="line"></span><br><span class="line">token = <span class="variable constant_">JWT</span>.encode(</span><br><span class="line">  &#123;</span><br><span class="line">    <span class="symbol">iss:</span> team_id,</span><br><span class="line">    <span class="symbol">iat:</span> Time.now.to_i,</span><br><span class="line">    <span class="symbol">exp:</span> Time.now.to_i + <span class="number">86400</span> * validity_period,</span><br><span class="line">    <span class="symbol">aud:</span> <span class="string">&quot;https://appleid.apple.com&quot;</span>,</span><br><span class="line">    <span class="symbol">sub:</span> client_id</span><br><span class="line">  &#125;,</span><br><span class="line">  private_key,</span><br><span class="line">  <span class="string">&quot;ES256&quot;</span>,</span><br><span class="line">  header_fields=&#123;</span><br><span class="line">    <span class="symbol">kid:</span> key_id </span><br><span class="line">  &#125;</span><br><span class="line">)</span><br><span class="line">puts token</span><br><span class="line"></span><br><span class="line"><span class="comment">#key_file：苹果开发者中心下载的.p8文件(实现-1步骤中提到的)保存的路径</span></span><br><span class="line"><span class="comment">#team_id：开发者账号的teamID(实现-2步骤中提到的)</span></span><br><span class="line"><span class="comment">#client_id：项目的bundleID</span></span><br><span class="line"><span class="comment">#key_id：苹果开发者中心创建的keyID(实现-2步骤中提到的)</span></span><br></pre></td></tr></table></figure>

<h6 id="4、Ruby文件的执行"><a href="#4、Ruby文件的执行" class="headerlink" title="4、Ruby文件的执行"></a>4、Ruby文件的执行</h6><p>cd到上面生成的ruby文件所在目录下，执行<strong>ruby iosAutoForServer.rb</strong>(如果Mac存在Ruby环境)，即可得到响应的client_secret</p>
<blockquote>
<p>好了，到此为止，后端完成了苹果的验证之后，后续业务该怎么玩怎么玩了，其实关于<code>Sign In with Apple</code>登录的文章一搜一大把，说来说去主要重点就是这么点东西，可能部分细节我这里没有实现，但是重点就是这些.</p>
</blockquote>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Albert Yuan</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://yllove.gitee.io/2021/10/26/iOS/%E8%8B%B9%E6%9E%9C%E7%AC%AC%E4%B8%89%E6%96%B9%E7%99%BB%E5%BD%95/">https://yllove.gitee.io/2021/10/26/iOS/%E8%8B%B9%E6%9E%9C%E7%AC%AC%E4%B8%89%E6%96%B9%E7%99%BB%E5%BD%95/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://yllove.gitee.io" target="_blank">Albert Yuan's Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/blog/tags/Objective-c/">Objective-c</a><a class="post-meta__tags" href="/blog/tags/ruby/">ruby</a><a class="post-meta__tags" href="/blog/tags/Sign-in-with-Apple/">Sign in with Apple</a></div><div class="post_share"><div class="social-share" data-image="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F1625283-e61716c6b5265137.png&amp;refer=http%3A%2F%2Fupload-images.jianshu.io&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1637827636&amp;t=1d207d66ff8d9377112e4eaef5dd90a5" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://fastly.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blog/2021/10/25/Flutter/flutter3-Dart%E8%AF%AD%E8%A8%80%E5%85%A5%E9%97%A8/"><img class="prev-cover" src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic3.zhimg.com%2Fv2-0831ab242b01a6de64757dfd7b0197d1_1200x500.jpg&amp;refer=http%3A%2F%2Fpic3.zhimg.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1634956133&amp;t=ecc2a799267cb1cd0dda77522b8d3062" onerror="onerror=null;src='/blog/img/defaultCover.gif'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">flutter3-Dart语言入门</div></div></a></div><div class="next-post pull-right"><a href="/blog/2021/10/27/iOS%20UIKIt/iOS%E5%AF%BC%E8%88%AA%E6%A0%8F%E9%81%AE%E6%8C%A1%E9%97%AE%E9%A2%98%E7%9A%84%E6%80%BB%E7%BB%93/"><img class="next-cover" src= "" data-lazy-src="/blog/img/defaultCover.png" onerror="onerror=null;src='/blog/img/defaultCover.gif'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">iOS导航栏遮挡问题的总结</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/blog/2021/08/10/iOS/ios-OC的多态/" title="ios Objective-c的多态理解"><img class="cover" src= "" data-lazy-src="https://img0.baidu.com/it/u=1459462488,4026553309&fm=26&fmt=auto&gp=0.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-10</div><div class="title">ios Objective-c的多态理解</div></div></a></div><div><a href="/blog/2021/10/12/iOS/ios定时器之NSTimer/" title="ios定时器之NSTimer"><img class="cover" src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F0119b95d5ba91aa80120695c98f29a.png&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1636599433&t=9db5e85b7ff3612a40187f12b62acd11" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-10-12</div><div class="title">ios定时器之NSTimer</div></div></a></div><div><a href="/blog/2021/08/26/iOS/启动引导页/" title="启动引导页"><img class="cover" src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F9463efc372704f16be50f4ed048109fadc01ff792dece-xClCWF_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1632538996&t=9535dbf2109e55b167748c259b88298d" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-26</div><div class="title">启动引导页</div></div></a></div><div><a href="/blog/2022/09/16/iOS/ios-keychain理解与使用/ios-keychain理解与使用/" title="ios keychain理解与使用"><img class="cover" src= "" data-lazy-src="/blog/img/defaultCover.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-09-16</div><div class="title">ios keychain理解与使用</div></div></a></div><div><a href="/blog/2022/10/21/iOS/iOS description与debugDescription在调试程序中的应用/" title="iOS description与debugDescription在调试程序中的应用"><img class="cover" src= "" data-lazy-src="/blog/img/defaultCover.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-10-21</div><div class="title">iOS description与debugDescription在调试程序中的应用</div></div></a></div><div><a href="/blog/2022/10/28/iOS/iOS-ViewController与View的生命周期/" title="iOS UIViewController和UIView的生命周期"><img class="cover" src= "" data-lazy-src="/blog/img/defaultCover.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-10-28</div><div class="title">iOS UIViewController和UIView的生命周期</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="/blog/img/favicon.png" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Albert Yuan</div><div class="author-info__description">博学之,审问之,慎思之,明辨之,笃行之</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">155</div></a></div><div class="card-info-data-item is-center"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">56</div></a></div><div class="card-info-data-item is-center"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/yuanliangYL"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/yuanliangYL" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:yuanliangios@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="qq:1023817403" target="_blank" title="QQ"><i class="fab fa-qq"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">love cat , love life</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%89%8D%E7%AB%AF%E9%83%A8%E5%88%86"><span class="toc-text">前端部分</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#1%E3%80%81%E5%BC%80%E5%8F%91Sign-In-with-Apple%E7%9A%84%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9"><span class="toc-text">1、开发Sign In with Apple的注意事项</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#2%E3%80%81iOS-Sign-In-with-Apple%E6%B5%81%E7%A8%8B"><span class="toc-text">2、iOS Sign In with Apple流程</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#3%E3%80%81%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="toc-text">3、代码实现</span></a></li></ol></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%90%8E%E7%AB%AF%E9%AA%8C%E8%AF%81%E9%83%A8%E5%88%86"><span class="toc-text">后端验证部分</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#1%E3%80%81%E5%89%8D%E7%AB%AF%E9%85%8D%E7%BD%AE"><span class="toc-text">1、前端配置</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#2%E3%80%81%E8%8B%B9%E6%9E%9C%E9%AA%8C%E8%AF%81%E6%8E%A5%E5%8F%A3%EF%BC%9Ahttps-appleid-apple-com-auth-token"><span class="toc-text">2、苹果验证接口：https:&#x2F;&#x2F;appleid.apple.com&#x2F;auth&#x2F;token</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#3%E3%80%81%E7%A7%98%E9%92%A5client-secret%E7%9A%84%E7%94%9F%E6%88%90"><span class="toc-text">3、秘钥client_secret的生成</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#4%E3%80%81Ruby%E6%96%87%E4%BB%B6%E7%9A%84%E6%89%A7%E8%A1%8C"><span class="toc-text">4、Ruby文件的执行</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/2023/02/07/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BD%91%E9%A1%B5%E4%B8%8B%E8%BD%BDIPA%E5%8C%85/" title="iOS 自定义网页下载IPA包"><img src= "" data-lazy-src="https://img.mp.itc.cn/upload/20170409/1a8f793d7282451cbd1beb6841608c90_th.jpeg" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="iOS 自定义网页下载IPA包"/></a><div class="content"><a class="title" href="/blog/2023/02/07/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BD%91%E9%A1%B5%E4%B8%8B%E8%BD%BDIPA%E5%8C%85/" title="iOS 自定义网页下载IPA包">iOS 自定义网页下载IPA包</a><time datetime="2023-02-07T02:46:29.851Z" title="更新于 2023-02-07 10:46:29">2023-02-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2023/02/06/Flutter/Flutter%E6%8E%A5%E5%85%A5%E5%8E%9F%E7%94%9F-iOS/" title="flutter接入原生-iOS"><img src= "" data-lazy-src="https://pic4.zhimg.com/v2-6a115fea4db1ad770dccf4119bfab36f_1440w.jpg?source=172ae18b" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="flutter接入原生-iOS"/></a><div class="content"><a class="title" href="/blog/2023/02/06/Flutter/Flutter%E6%8E%A5%E5%85%A5%E5%8E%9F%E7%94%9F-iOS/" title="flutter接入原生-iOS">flutter接入原生-iOS</a><time datetime="2023-02-07T01:18:53.661Z" title="更新于 2023-02-07 09:18:53">2023-02-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2022/12/17/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS%20%E5%A6%82%E4%BD%95%E5%9C%A8%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%B8%AD%E5%AE%89%E8%A3%85APP/" title="iOS 如何在模拟器中安装APP"><img src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.winwin7.com%2Fuploadfile%2F2021%2F0114%2F20210114141748239.jpg&amp;refer=http%3A%2F%2Fwww.winwin7.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1673854539&amp;t=aad2108ffb799b04e94a28cc58f038f1" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="iOS 如何在模拟器中安装APP"/></a><div class="content"><a class="title" href="/blog/2022/12/17/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS%20%E5%A6%82%E4%BD%95%E5%9C%A8%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%B8%AD%E5%AE%89%E8%A3%85APP/" title="iOS 如何在模拟器中安装APP">iOS 如何在模拟器中安装APP</a><time datetime="2022-12-17T07:48:56.594Z" title="更新于 2022-12-17 15:48:56">2022-12-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021/08/05/Swift/swift%E5%B8%B8%E7%94%A8%E4%B8%89%E6%96%B9%E5%BA%93/" title="swift常用三方库"><img src= "" data-lazy-src="https://photos.infinum.com/store/b558bd40787ecad225d9c66322f14522" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="swift常用三方库"/></a><div class="content"><a class="title" href="/blog/2021/08/05/Swift/swift%E5%B8%B8%E7%94%A8%E4%B8%89%E6%96%B9%E5%BA%93/" title="swift常用三方库">swift常用三方库</a><time datetime="2022-12-16T06:37:20.115Z" title="更新于 2022-12-16 14:37:20">2022-12-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2022/12/12/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/GCD%E8%BF%9B%E9%98%B6%E4%B9%8BDispatchWorkItem%E5%92%8CDispatchGroup/" title="GCD进阶之DispatchWorkItem和DispatchGroup"><img src= "" data-lazy-src="/blog/img/defaultCover.png" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="GCD进阶之DispatchWorkItem和DispatchGroup"/></a><div class="content"><a class="title" href="/blog/2022/12/12/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/GCD%E8%BF%9B%E9%98%B6%E4%B9%8BDispatchWorkItem%E5%92%8CDispatchGroup/" title="GCD进阶之DispatchWorkItem和DispatchGroup">GCD进阶之DispatchWorkItem和DispatchGroup</a><time datetime="2022-12-12T07:19:37.277Z" title="更新于 2022-12-12 15:19:37">2022-12-12</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F1625283-e61716c6b5265137.png&amp;refer=http%3A%2F%2Fupload-images.jianshu.io&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1637827636&amp;t=1d207d66ff8d9377112e4eaef5dd90a5')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By Albert Yuan</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Hi, welcom to my  blog</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><div class="search-dialog__title" id="algolia-search-title">Algolia</div><div id="algolia-input-panel"><div id="algolia-search-input"></div></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-stats"></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="https://fastly.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/blog/js/search/algolia.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    chtml: {
      scale: 1.2
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        insertScript: [200, () => {
          document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
            const target = node.parentNode
            if (target.nodeName.toLowerCase() === 'li') {
              target.parentNode.classList.add('has-jax')
            } else {
              target.classList.add('has-jax')
            }
          });
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://fastly.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'REc8eytE1gJDl3d8FkudLNlL-gzGzoHsz',
      appKey: 'gGO3y8I9oVlc4Cd5N1fizNPW',
      avatar: 'monsterid',
      serverURLs: '',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://fastly.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script id="canvas_nest" defer="defer" color="255,0,0" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script><script src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>